package com.dgcsxy.cat_eyes_movies.common.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult {

    /**
     * 返回消息提示
     */
    private String message;
    /**
     * 返回状态码
     */
    private int status;
    /**
     * 返回数据
     */
    private Object data;


    public ResponseResult(ResponseState responseState) {
        this.status = responseState.getStatus();
        this.message = responseState.getMessage();
    }

    /**
     * 操作成功
     *
     * @return
     */
    public static ResponseResult SUCCESS() {
        return new ResponseResult(ResponseState.SUCCESS);
    }

    /***
     * 操作失败
     *
     * @return
     */
    public static ResponseResult FAILED() {
        return new ResponseResult(ResponseState.FAILED);
    }

    /**
     * 系统异常
     *
     * @return
     */
    public static ResponseResult SYSTEM_ERROR() {
        return new ResponseResult(ResponseState.SYSTEM_ERROR);
    }

    /**
     * 操作成功
     *
     * @param message
     * @param data
     * @return
     */
    public static ResponseResult SUCCESS(String message, Object data) {
        ResponseResult responseResult = new ResponseResult();
        responseResult.setStatus(0);
        responseResult.setMessage(message);
        responseResult.setData(data);
        return responseResult;
    }

    /**
     * 操作成功
     *
     * @param data
     * @return
     */
    public static ResponseResult SUCCESS(Object data) {
        ResponseResult responseResult = new ResponseResult();
        responseResult.setStatus(0);
        responseResult.setMessage("操作成功");
        responseResult.setData(data);
        return responseResult;
    }

    /**
     * 操作失败
     *
     * @param message
     * @return
     */
    public static ResponseResult FAILED(String message) {
        ResponseResult responseResult = new ResponseResult();
        responseResult.setStatus(1);
        responseResult.setMessage(message);
        return responseResult;
    }

    /**
     * 操作失败
     *
     * @param status
     * @param message
     * @return
     */
    public static ResponseResult FAILED(int status, String message) {
        ResponseResult responseResult = new ResponseResult();
        responseResult.setStatus(status);
        responseResult.setMessage(message);
        return responseResult;
    }
}
